****APPENDIX TABLE D6****

cd "$main_dir/output/tables/appendix_d"

global basic 	sex marital religion edu ethnicity birth_state
global extra	employment_status occupation income urban
global time 	survey_year age generation
global polit    party partisan

//--------------------------------------------------------
//Define relevant program
//--------------------------------------------------------

capture program drop standardize
program define standardize
	
	args depvar
	
	cap drop z*
	local varlist `depvar' wgrowth_rate_1 yob_ln_gdppc
	foreach var of local varlist {
		egen z`var' = std(`var') if e(sample)==1
}														

end

//--------------------------------------------------------
//Read in relevant data
//--------------------------------------------------------

clear
use "$data_dir/clean/anes_final.dta"

egen scode_survey_year = group(state_code survey_year)
egen survey_year_yob = group(survey_year yob)
egen birth_state_yob = group(birth_state yob)

//--------------------------------------------------------
//Create Table D6 (Panel A)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(state_code yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(state_code yob)
outreg2 using table_d6_panel_a.doc, replace dec(3) nocons addtext(Cluster, State & Cohort) keep(zwgrowth_rate_1) 														
				
//Column 2		
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(survey_year_yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(survey_year_yob)
outreg2 using table_d6_panel_a.doc, append dec(3) nocons addtext(Cluster, Survey Year x Cohort) keep(zwgrowth_rate_1) 														
					
//Column 3					
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(birth_state_yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(birth_state_yob)
outreg2 using table_d6_panel_a.doc, append dec(3) nocons addtext(Cluster, Birth State x Cohort) keep(zwgrowth_rate_1) 														
					
//Column 4					
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(birth_state_yob survey_year)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(state_code $time $basic $extra $polit) cluster(birth_state_yob survey_year)
outreg2 using table_d6_panel_a.doc, append dec(3) nocons addtext(Cluster, Birth State x Cohort & Survey Year) keep(zwgrowth_rate_1) 
															
//--------------------------------------------------------
//Create Table D6 (Panel B)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(state_code yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(state_code yob)
outreg2 using table_d6_panel_b.doc, replace dec(3) nocons addtext(Cluster, State & Cohort) keep(zwgrowth_rate_1) 														
						
//Column 2						
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(survey_year_yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(survey_year_yob)
outreg2 using table_d6_panel_b.doc, append dec(3) nocons addtext(Cluster, Survey Year x Cohort) keep(zwgrowth_rate_1) 														
						
//Column 3						
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(birth_state_yob)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(birth_state_yob)
outreg2 using table_d6_panel_b.doc, append dec(3) nocons addtext(Cluster, Birth State x Cohort) keep(zwgrowth_rate_1) 														
							
//Column 4							
qui reghdfe trust_fed_govt wgrowth_rate_1 yob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(birth_state_yob survey_year)
standardize trust_fed_govt
reghdfe ztrust_fed_govt zwgrowth_rate_1 zyob_ln_gdppc, absorb(scode_survey_year $time $basic $extra $polit) cluster(birth_state_yob survey_year)
outreg2 using table_d6_panel_b.doc, append dec(3) nocons addtext(Cluster, Birth State x Cohort & Survey Year) keep(zwgrowth_rate_1) 

